'use strict';
const formRules = require("../util/formRules.js")
module.exports = {
	/**
	 * 添加推广
	 * @url admin/popularize/sys/add 前端调用的url参数地址
	 * data 请求参数 说明
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		let { data = {}, userInfo, util, filterResponse, originalParam } = event;
		let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
		let { uid } = data;
		let res = { code: 0, msg: "" };
		// 业务逻辑开始-----------------------------------------------------------
		// 参数合法校验开始-----------------------------------------------------------
		let formRulesRes = await formRules.add(event);
		
		if (formRulesRes.code !== 0) {
			return formRulesRes;
		}
		// 参数合法校验结束-----------------------------------------------------------

		let dbName = "db-popularize";
		
		// 执行数据库API请求
		res.id = await vk.baseDao.add({
			dbName,
			dataJson: data
		});
		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}
